<%@ page language="java" import="java.util.*,base.*,pojo.*,service.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
  <head>
    <title>阜阳白金汉宫网上订餐</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap -->
    <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
	 <link href="../bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
	 <link href="../bootstrap/css/commom.css" />
	 
<style type="text/css">

.STYLE1 {font-size: 18px}
.STYLE2 {font-size: 24px}
 * { margin:0; padding:0; }
body { background:#FFF; color:#333; font:12px/1.6em Helvetica, Arial, sans-serif; }
a { color:#0287CA; text-decoration:none; }
a:hover { text-decoration:underline; }
ul, li { list-style:none; }
fieldset, img { border:none; }
legend { display:none; }
em, strong, cite, th { font-style:normal; font-weight:normal; }
input, textarea, select, button { font:12px Helvetica, Arial, sans-serif; }
table { border-collapse:collapse; }
html { overflow:-moz-scrollbars-vertical; } 

.content_box_left_main_right_c_ul li {
    float: left;
    height: 400px;
    margin-bottom: 30px;
    margin-right: 30px;
    overflow: hidden;
    text-align: left;
    width: 144px;
    padding:0;
}
.content_box_left_main_right_c {
    display: block;
    overflow: hidden;
    padding-left: 2px;
    width: 100%;
}
.content_box_left_main_right_c_ul_li_1 {
    display: block;
    height: 73px;
    margin-top: 5px;
    padding-left: 5px;
    text-align:center;
}
.content_box_left_main_right_c_ul_li_2 {
    padding-bottom: 5px;
    text-align: center;
}
.content_box_left_main_right_c_ul_li_3 {
    display: block;
    height: 43px;
    margin-top: 5px;
    padding-left: 5px;
    color:red;
    text-align:center;
    margin-bottom: 10px;
}
.content_box_left_main_right_c_ul_li_4{
    display: block;
    height: 30px;
    margin-top: 5px;
    padding-left: 5px;
    text-align:center;
     margin-bottom: 40px;
}

#clear_div {
    clear: both;
}
img{width:160px;height:160px;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}

</style>
<script type="text/javascript" src="${pageContext.request.contextPath }/jquery/jquery-1.7.2.min.js"></script>
<script src="../bootstrap/js/bootstrap.js"></script>
<script src="../bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(function(){
$('.o').tooltip();
$('.btn-warning').tooltip();
$('.dropdown-toggle').dropdown();
})
function add(url){
  location.href=url;
 }
</script>
<script type="text/javascript">
$(function(){
	$("#ok").click(function(){
	var dishesname=$("#select").val();
    if(dishesname==""){
	alert("要想查询，要先输入您想要吃的菜哦！亲");
	return false;
	}
    else $("#form").submit();
	
	})
})


</script>
</head>
  <body>
   <div class="navbar navbar-inverse navbar-fixed-top">
       <div class="navbar-inner">
           <div class="container-fluid">
              <a class="brand" href="index.jsp">白金汉宫网上订餐</a>
                    <div class="nav-collapse collapse">
                      <ul class="nav">
                        <li class="active">
                          <a href="index.jsp">主页</a>
                     </li>
                       </ul>
                             <p class="navbar-text pull-right">
    <%
        
		String username = (String)session.getAttribute( "name" );
		CartService cs= new CartService();
		if ( username == null || username == "" )
		{
	%>
<a class="navbar-link" href="login.jsp">登录</a>&nbsp;&nbsp;&nbsp;<a class="navbar-link" href="regest.jsp">注册</a>
    <%
} 
	else
	{
		int userid=(Integer)session.getAttribute("id");
		int cartNum=cs.getALL(userid);
			out.println( "欢迎您! "+username  );
			out.println("<a href='memberzone.jsp' role='button' class='btn btn-success' >个人中心</a>");
			out.println("<a href='cartlist.jsp' data-placement='bottom' role='button' class='btn btn-warning' data-toggle='tooltip' title='ffff'>我的购物车"+cartNum+"</a>");
			out.println( "<a href='destroySession.jsp' role='button' class='btn btn-danger' >安全退出</a>" );
	}
     %>
</p>
	                 </div>   
                 </div>
             </div>
         </div>
         <div class="span12" style="width: 1300px; height: 50px;margin-bottom: 5px;">
             <form id="form" class="form-search" style="float:right;margin-top:20px;" action="selectList.jsp" method="post">
                <input type="text" name="select" id="select" class="input-medium search-query" style="width: 200px;margin-right:10px;"placeholder="快速查询">
                   <button type="button" class="btn" id="ok">Search</button>
                          </form>
         
         </div>
            <div class="container-fluid">
                <div class="row-fluid">
                     <div class="span3">
                          <div class="well sidebar-nav">
                              <ul class="nav nav-list">
                                <li class="nav-header STYLE2">菜单</li>
   <%                          DishesService ds = new DishesService();	
	                           List<dishesType> list1 = ds.getDishesType();	
	                           for(dishesType d:list1){
			                     out.print("<li> <a href='dishes.jsp?type="+d.getId()+"'  class='STYLE1'>"+d.getName()+"</a></li>");
	                           } 
    %>
                               </ul>
                            </div>
                         </div>
                             <div class="span9">
                             <%
	request.setCharacterEncoding("utf-8");
    String spageno = request.getParameter("pageno");
    int type = Integer.parseInt(request.getParameter("type"));
    int pageno;
    int pagesize=10;
    if(spageno==null){ pageno = 1;}
    else pageno=Integer.valueOf(request.getParameter("pageno"));
    DishesService us = new DishesService();
    int size=us.getAllByType(type);
    String ob = "";
    int orderby;
    if(request.getParameter("orderby")!=null){
    orderby=Integer.parseInt(request.getParameter("orderby"));
    if(orderby==0){
    ob+="order by price ";
    }
    if(orderby==1){
    ob+="order by price desc";
    }
    if(orderby==2){
    ob+="order by orderNum ";
    }
    if(orderby==3){
    ob+="order by orderNum desc ";
    }
    
    }
   else{orderby=5;}
    
	try{pageno = Integer.parseInt(spageno);}
	catch(Exception e){}
		

	Page p1=new Page();
								p1.setTotalRecord(size);
								p1.setCurrentPageNo(pageno);
								p1.setPageSize(pagesize);	
	List<dishes> list = us.getDishesByType(pageno,pagesize,type,ob);//按参数查询
		  
		

			
%>
                             
                             
<div class="hero-unit">

<div class="btn-group">
<button class="btn btn-danger dropdown-toggle" data-toggle="dropdown">
排序方式
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<a href='dishes.jsp?orderby=0&&type=<%=Integer.parseInt(request.getParameter("type")) %>'>价格从低到高</a>
</li>
<li>
<a href='dishes.jsp?orderby=1&&type=<%=Integer.parseInt(request.getParameter("type")) %>'>价格从高到低</a>
</li>
<li>
<a href='dishes.jsp?orderby=2&&type=<%=Integer.parseInt(request.getParameter("type")) %>'>销量从低到高</a>
</li>
<li>
<a href='dishes.jsp?orderby=3&&type=<%=Integer.parseInt(request.getParameter("type")) %>'>销量从高到低</a>
</li>
</ul>
</div>






                                
 
          
                             <div id="showProductsNew" style="display: block;">
                              
                                         <div id="showP_c" style="">
<table width="100%" cellspacing="0" cellpadding="0" border="0"style="margin-top:30px;" >
<tbody>
<tr>
<td class='content_box_left_main_right_c'><ul class='content_box_left_main_right_c_ul'>
<%
    int foodtype=-1;
	for (dishes inf : list) {
	out.println(
	"<li id="+inf.getId()+"><a href='../"+inf.getPicture()+"' data-toggle='tooltip' class='o' data-delay=500 data-placement='right' title='"+inf.getDetail()+"'><img src='../"+inf.getPicture()+"'></a>");	  
	out.println("<span class='content_box_left_main_right_c_ul_li_1' style='margin-top:3px'><strong><a href='dishesDetail.jsp?id="+inf.getId()+"'>"+inf.getName()+"</a></strong><div class='content_box_left_main_right_c_ul_li_1_1'><span class='content_box_left_main_right_c_ul_li_1_1_l'>"+inf.getPrice()+"元/份</span></div></span>");
	out.println("<span class='content_box_left_main_right_c_ul_li_4' style='margin-top:3px'> "+inf.getQuality()+"</span>");
	if(inf.getSale()==10){
	out.println("<span class='content_box_left_main_right_c_ul_li_3' style='margin-top:3px'></span>");}
	else out.println("<span class='content_box_left_main_right_c_ul_li_3' style='margin-top:3px'> "+inf.getSale()+"折</span>");
	out.println("<span class='content_box_left_main_right_c_ul_li_2'> <center><button class='btn btn-danger' type='button' onclick=add('../action/websiteAction/orderAction.jsp?dishesId="+inf.getId()+"&type="+inf.getType()+"')>加入菜单</button><center></span></li>");
	foodtype=inf.getType();
	}
	%>
</ul>
                        <div id="clear_div"></div>
</td>
</tr>
<%
    if(foodtype<0){
    out.print("<tr><td class='content_box_left_main_right_c' colspan='9'><h5>共"+p1.getTotalPage()+"页，当前第"+pageno+"页， ---上一页");
								 out.print("下一页</h5></td></tr>");

    
    }
    
    else{
  
    
	out.print("<tr><td class='content_box_left_main_right_c' colspan='9'><h5>共"+p1.getTotalPage()+"页，当前第"+pageno+"页， ---<a href='dishes.jsp?type="+foodtype+"&pageno="+p1.getPrePage()+"&orderby="+orderby+"'>上一页</a>");
								 out.print("<a href='dishes.jsp?type="+foodtype+"&&pageno="+p1.getNextPage()+"&orderby="+orderby+"'>下一页</a><input type=text name=pagenum id=pagenum style=width:20;border:1px solid grey> <a href='javascript:void(0);' onclick=openpage();>跳转</a></h5></td></tr>");
}
%>	
</tbody>
</table>
 
 
  </div>
  </div>
   
   </div> 
    </div>



</div>  
<hr>
<footer>
<p>版权所有</p>
</footer> 
</div>
  </body>
</html>
